#include <stdio.h>

int n, m;
int map[103][103] = {};

int ismine(int i, int j)
{
    return ((map[i][j]) == -1);
}

int main()
{
    scanf("%d%d", &n, &m);
    char t;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            t = getchar();
            if (t == '\n')
                t = getchar();
            int tmp;
            switch (t)
            {
            case '*':
                tmp = -1;
                break;
            case '?':
                tmp = -2;
                break;
            default:
                tmp = -2;
                break;
            }
            map[i][j] = tmp;
        }
    }

/*     for (int i = 0; i <= n + 1; ++i)
    {
        for (int j = 0; j <= m + 1; ++j)
        {
            printf("%c ", (map[i][j] == -1) ? '*' : (map[i][j] + '0'));
        }
        putchar('\n');
    }
    putchar('\n'); */

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
        {
            if (map[i][j] == -2)
            {
                map[i][j] = ismine(i - 1, j - 1) + ismine(i - 1, j) + ismine(i - 1, j + 1) +
                            ismine(i, j - 1) + ismine(i, j + 1) +
                            ismine(i + 1, j - 1) + ismine(i + 1, j) + ismine(i + 1, j + 1);
            }
        }

    for (int i = 1; i <= n; ++i)
    {
        for (int j = 1; j <= m; ++j)
        {
            printf("%c", (map[i][j] == -1) ? '*' : (map[i][j] + '0'));
        }
        putchar('\n');
    }
    return 0;
}